-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/ownership requests #740
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Off to a great start! Left some comments; feel free to reply/reach out with any questions. Please also add some test cases when you get a chance 🙂
backend/clubs/admin.py
Outdated
"person__username", | ||
"person__email", | ||
"club__name", | ||
"club__pk", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
club_pk
might not be as useful as a search field
@@ -0,0 +1,41 @@ | |||
# Generated by Django 5.0.4 on 2024-10-06 05:12 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a merge file, would recommend deleting this, merging the latest changes from master, and remaking the migration file. After doing this, you might have to fake the migration locally in order to reach a consistent state.
backend/clubs/models.py
Outdated
@@ -1122,6 +1122,54 @@ class Meta: | |||
unique_together = (("person", "club"),) | |||
|
|||
|
|||
class OwnershipRequest(models.Model): | |||
""" | |||
Used when users request ownership from the owner |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would suggest saying something like "Represents a user's request to take ownership of a club"
backend/clubs/models.py
Outdated
person = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) | ||
club = models.ForeignKey(Club, on_delete=models.CASCADE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it's good practice to define a related_name
for foreign key fields. Also nit: would suggest renaming person
field to something like requester
backend/clubs/models.py
Outdated
person = models.ForeignKey(get_user_model(), on_delete=models.CASCADE) | ||
club = models.ForeignKey(Club, on_delete=models.CASCADE) | ||
|
||
withdrew = models.BooleanField(default=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: withdrawn
backend/clubs/views.py
Outdated
) | ||
|
||
|
||
class OwnershipRequestOwnerViewSet(XLSXFormatterMixin, viewsets.ModelViewSet): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the XLSXFormatterMixin
here? Don't foresee there being enough ownership requests for them to be exported to CSV
backend/clubs/views.py
Outdated
return Response({"success": True}) | ||
|
||
|
||
class OwnershipRequestSuperuserAPIView(generics.ListAPIView): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor of consolidating this view into the previous one and renaming it OwnershipRequestManagementViewSet
. You should then be able to create a separate route under this viewset to achieve the same functionality. @aviupadhyayula lmk what you think about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, agreed.
@@ -0,0 +1,17 @@ | |||
<!-- TYPES: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ownership_request.html
, and rename request.html
to membership_request.html
{% extends 'emails/base.html' %} | ||
|
||
{% block content %} | ||
<h2>Ownership Request from <b>{{ full_name }}</b> for <b>{{ club_name }}</b></h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Request for ownership for club_name
from full_name
|
||
{% block content %} | ||
<h2>Ownership Request from <b>{{ full_name }}</b> for <b>{{ club_name }}</b></h2> | ||
<p style="font-size: 1.2em"><b>{{ full_name }}</b> sent an ownership request to join <b>{{ club_name }}</b> through the Penn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ...has submitted a request for ownership of club_name
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, this looks like a great start! Rohan was (very) thorough, not much to add. One last nit: consider updating the PR's title and description to be a little more descriptive. (Take a look at past PRs for examples.) It's a small detail, but when you're reviewing code years in the future, it's great to understand what the author was thinking.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #740 +/- ##
==========================================
- Coverage 71.80% 71.56% -0.24%
==========================================
Files 31 31
Lines 6901 7013 +112
==========================================
+ Hits 4955 5019 +64
- Misses 1946 1994 +48 ☔ View full report in Codecov by Sentry. |
Make Ownership Requests feature with new model OwnershipRequest.